﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.Web.Security;

namespace SPCIT.SP2010.Portal
{
    public abstract class SPCITProvidersBaseWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
        [Personalizable(PersonalizationScope.Shared), WebBrowsable(true)]
        public string RoleProviderName { get; set; }

        [Personalizable(PersonalizationScope.Shared), WebBrowsable(true)]
        public string MembershipProviderName { get; set; }

        protected MembershipProvider GetConfiguredMembershipProvider()
        {
            MembershipProvider result = null;

            if (!String.IsNullOrEmpty(this.MembershipProviderName))
            {
                result = Membership.Providers[this.MembershipProviderName];
            }
            else
            {
                result = Membership.Provider;
            }

            return (result);
        }

        protected RoleProvider GetConfiguredRoleProvider()
        {
            RoleProvider result = null;

            if (!String.IsNullOrEmpty(this.RoleProviderName))
            {
                result = Roles.Providers[this.RoleProviderName];
            }
            else
            {
                result = Roles.Provider;
            }
         
            return (result);
        }
    }
}
